<template>
  <div>
    <el-form
      :inline="inline"
      :model="form"
      ref="form"
      label-width="100px"
      v-loading="loading"
    >
      <el-form-item
        v-for="item in formLabel"
        :key="item.model"
        :label="item.label"
      >
        <input
          v-if="item.type === 'hidden'"
          type="hidden"
          v-model="form[item.model]"
        />
        <el-input
          v-if="!item.type"
          v-model="form[item.model]"
          :placeholder="'请输入' + item.label"
        ></el-input>
        <el-select
          v-model="form[item.model]"
          v-if="item.type === 'select'"
          placeholder="请选择"
        >
          <el-option
            v-for="subItem in item.opts"
            :key="subItem.value"
            :label="subItem.label"
            :value="subItem.value"
          ></el-option>
        </el-select>
        <el-switch
          v-if="item.type === 'switch'"
          v-model="form[item.model]"
        ></el-switch>
        <el-date-picker
          v-model="form[item.model]"
          type="date"
          placeholder="选择日期"
          v-if="item.type === 'date'"
          :value-format="dataFormat ? dataFormat : 'yyyy-MM-dd'"
        >
        </el-date-picker>
        <el-input
          placeholder="请输入密码"
          v-model="form[item.model]"
          show-password
          v-if="item.type === 'password'"
        >
        </el-input>
      </el-form-item>
      <el-form-item>
        <slot></slot>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    inline: Boolean,
    form: Object,
    formLabel: Array,
    loading: Boolean,
    dataFormat: String
  }
};
</script>

<style scoped></style>
